/**
 * @file
 * @brief event filters for various needs
 * @date 2021-09-20
 */

#pragma once

#include <QObject>

/**
 * @class SelectAllOnFocusIn
 * @brief select all text for QAbstractSpinBox on FocusIn event
 */
class SelectAllOnFocusIn : public QObject
{
    Q_OBJECT
public:
    explicit SelectAllOnFocusIn( QObject * parent = nullptr )
        : QObject( parent ) {}

protected:
    bool eventFilter( QObject * watched, QEvent * event ) override;
};

/**
 * @class ConvertFromLocaleNumber
 * transform string presentation from locale string to string for QLineEdit
 * examples:
 *  1,234.00    => 1234
 *  9,464,654   => 9464654
 */
class ConvertFromLocaleNumber : public QObject
{
    Q_OBJECT
public:
    explicit ConvertFromLocaleNumber( QObject * parent = nullptr )
        : QObject( parent ) {}

protected:
    bool eventFilter( QObject * watched, QEvent * event ) override;
};
